package com.langfeiyes.pattern.proxy.demo;

/**
 * 代理对象
 */
public class EmployeeProxy implements IEmployeeService {

    private EmployeeServiceImpl employeeService;

    public EmployeeProxy(EmployeeServiceImpl employeeService){
        this.employeeService = employeeService;
    }

    @Override
    public void save() {
        //权限判断
        if("admin".equals(SessionHolder.getCurrentUser())){
            employeeService.save();
        }else{
            throw new RuntimeException("当前非admin用户，不能执行save操作");
        }
    }

    @Override
    public void list() {
        employeeService.list();
    }
}
